<!DOCTYPE html>
<html lang="en">
    <head>
        <?php include(__DIR__ . '/../common/header.phtml'); ?>
        <style type="text/css">
            .btn-filter .btn {padding:3px 6px;}
            .btn-filter .btn .caret{margin:0;}
        </style>
    </head>
    <body>
        <div class="wrapper">
            <?php include(__DIR__ . '/../common/menu.phtml'); ?>
            <div class="page-wrapper">
                <?php include(__DIR__ . '/../common/intro.phtml'); ?>
                <div class="page-content">
                    <div class="toolbar">
                        <div class="pull-left">
                            <button class="btn btn-primary"><span class="fa fa-refresh"></span></button>
                            <button class="btn btn-primary" data-event="dtmulti" data-action="add" data-ids="0">新增</button>
                            <button class="btn btn-primary" data-event="dtmulti" data-action="del" disabled="true">删除</button>
                        </div>

                    </div>
                    <table id="example" class="table table-hover">
                        <thead>
                            <tr>
                                <th><input type="checkbox" name="select-all" value="1" class="select-all"></th>
                                <th>ID</th>
                                <th>类型</th>
                                <th>URL</th>
                                <th>文件大小</th>
                                <th>上传时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>

                    </table>
                </div>
            </div>
        </div>
        <?php include(__DIR__ . '/../common/footer.phtml'); ?>
        <script type="text/javascript">
            $(function () {
                dtinit("#example").dataTable({
                    "custom": {
                        "toolbardom": ".toolbar",
                        "add_url": "<?= Tools::siteurl("attachment/add") ?>",
                        "edit_url": "<?= Tools::siteurl("attachment/edit") ?>",
                        "del_url": "<?= Tools::siteurl("attachment/del") ?>",
                        "move_url": "<?= Tools::siteurl("attachment/move") ?>",
                        "multi_url": "<?= Tools::siteurl("attachment/multi") ?>",
                    },
                    "ajax": {
                        "url": '<?= Tools::siteurl("attachment/index") ?>',
                        "data": function (d) {
                            d = $.extend(d, dtfilter(d));
                        }
                    },
                    'columnDefs': [{
                            'targets': 0,
                            'searchable': false,
                            'orderable': false,
                            'render': function (data, type, full, meta) {
                                return '<input type="checkbox" name="id[]" value="' + $('<div/>').text(data).html() + '">';
                            }
                        }, {
                            'targets': 6,
                            'searchable': false,
                            'orderable': false,
                            'render': function (data, type, full, meta) {
                                return '<a href="javascript:;" data-event="dtmulti" data-ids="' + data + '" data-action="del"><span class="fa fa-remove"></span> 删除</a>';
                            }
                        }, {
                            'targets': [1, 2],
                            'searchable': false,
                            'orderable': false,
                        }
                    ],
                    "columns": [
                        {"data": "id"},
                        {"data": "id"},
                        {"data": "type"},
                        {"data": "url"},
                        {"data": "size"},
                        {"data": "createtime"},
                        {"data": "id"}
                    ]
                });
            });
        </script>
    </body>
</html>
